<template>
	<div>
		<AplidForm ref="formRef" v-bind="OtherFormConfig" v-model="formModel" @submit="onSubmit"> </AplidForm>
	</div>
</template>

<script setup lang="ts">
import { OtherFormConfig } from '../../config'
import { useCommonStore } from '@/stores/common'
const { setTempParams } = useCommonStore()

const emit = defineEmits(['submit'])
const formRef = ref(null)
const rowData: any = inject('nowRowData')
let otherMod = rowData.value?.data?.dpServiceObjectOthers || {}
let baseData = rowData.value?.baseData?.dpServiceObjectOthers || {}

const formModel = ref({
	...otherMod,
})
const onSubmit = (form, done) => {
	const { tempNowObj } = storeToRefs(useCommonStore())
	const changeObj = {
		data: [],
		dataChangeContentList: [
			{
				changeBefore: {
					...baseData,
          idCard: tempNowObj.value.idCard,
				},
				changeAfter: {
					...form,
          idCard: tempNowObj.value.idCard,
				},
				changeData: form,
				changeType: '服务对象其他信息',
				code: 1005,
			},
		],
		code: 1005,
	}

	setTempParams({
		name: tempNowObj.value.name,
		idCard: tempNowObj.value.idCard,
		nowChange: changeObj,
	})
	emit('submit', changeObj)
}

const onSave = () => {
	formRef.value!.onSubmit()
}
defineExpose({
	onSave,
})
</script>

<style scoped></style>
